home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / k3bdatadoc.h < prev    next >
Encoding:
C/C++ Source or Header  |  2008-05-27  |  7.9 KB  |  298 lines

  1. /* 
  2.  *
  3.  * $Id: k3bdatadoc.h 619556 2007-01-03 17:38:12Z trueg $
  4.  * Copyright (C) 2003 Sebastian Trueg <trueg@k3b.org>
  5.  *
  6.  * This file is part of the K3b project.
  7.  * Copyright (C) 1998-2007 Sebastian Trueg <trueg@k3b.org>
  8.  *
  9.  * This program is free software; you can redistribute it and/or modify
  10.  * it under the terms of the GNU General Public License as published by
  11.  * the Free Software Foundation; either version 2 of the License, or
  12.  * (at your option) any later version.
  13.  * See the file "COPYING" for the exact licensing terms.
  14.  */
  15.  
  16.  
  17. #ifndef K3BDATADOC_H
  18. #define K3BDATADOC_H
  19.  
  20. #include <k3bdoc.h>
  21. #include <k3bdataitem.h>
  22.  
  23. #include "k3bisooptions.h"
  24.  
  25. #include <qptrlist.h>
  26. #include <qfileinfo.h>
  27. #include <qstringlist.h>
  28.  
  29. #include <kurl.h>
  30. #include <kio/global.h>
  31. #include "k3b_export.h"
  32.  
  33. class K3bDataItem;
  34. class K3bRootItem;
  35. class K3bDirItem;
  36. class K3bFileItem;
  37. class K3bJob;
  38. class K3bBootItem;
  39. class K3bFileCompilationSizeHandler;
  40.  
  41. class KProgressDialog;
  42. //class K3bView;
  43. class KConfig;
  44. class QString;
  45. class QStringList;
  46. class QWidget;
  47. class QDomDocument;
  48. class QDomElement;
  49. class K3bIso9660Directory;
  50.  
  51. namespace K3bDevice {
  52.   class Device;
  53.   class DeviceHandler;
  54. }
  55.  
  56.  
  57. /**
  58.  *@author Sebastian Trueg
  59.  */
  60.  
  61. class LIBK3B_EXPORT K3bDataDoc : public K3bDoc
  62. {
  63.   Q_OBJECT
  64.  
  65.  public:
  66.   K3bDataDoc( QObject* parent = 0 );
  67.   virtual ~K3bDataDoc();
  68.  
  69.   virtual int type() const { return DATA; }
  70.   virtual QString typeString() const;
  71.  
  72.   virtual QString name() const;
  73.  
  74.   enum MultiSessionMode { 
  75.     /**
  76.      * Let the K3bDataJob decide if to close the CD or not.
  77.      * The decision is based on the state of the inserted media
  78.      * (appendable/closed), the size of the project (will it fill 
  79.      * up the CD?), and the free space on the inserted media.
  80.      */
  81.     AUTO,
  82.     NONE, 
  83.     START, 
  84.     CONTINUE, 
  85.     FINISH
  86.   };
  87.  
  88.   K3bRootItem* root() const { return m_root; }
  89.  
  90.   virtual bool newDocument();
  91.   virtual KIO::filesize_t size() const;
  92.  
  93.   /**
  94.    * This is used for multisession where size() also returnes the imported session's size
  95.    */
  96.   virtual KIO::filesize_t burningSize() const;
  97.   virtual K3b::Msf length() const;
  98.   virtual K3b::Msf burningLength() const;
  99.  
  100.   /**
  101.    * Simply deletes the item if it is removable (meaning isRemovable() returns true.
  102.    * Be aware that you can remove items simply by deleting them even if isRemovable()
  103.    * returns false.
  104.    */
  105.   void removeItem( K3bDataItem* item );
  106.  
  107.   /**
  108.    * Simply calls reparent.
  109.    */
  110.   void moveItem( K3bDataItem* item, K3bDirItem* newParent );
  111.   void moveItems( QPtrList<K3bDataItem> itemList, K3bDirItem* newParent );
  112.  
  113.   K3bDirItem* addEmptyDir( const QString& name, K3bDirItem* parent );
  114.     
  115.   QString treatWhitespace( const QString& );
  116.     
  117.   virtual K3bBurnJob* newBurnJob( K3bJobHandler* hdl, QObject* parent = 0 );
  118.     
  119.   MultiSessionMode multiSessionMode() const { return m_multisessionMode; }
  120.   void setMultiSessionMode( MultiSessionMode mode );
  121.  
  122.   int dataMode() const { return m_dataMode; }
  123.   void setDataMode( int m ) { m_dataMode = m; }
  124.  
  125.   void setVerifyData( bool b ) { m_verifyData = b; }
  126.   bool verifyData() const { return m_verifyData; }
  127.  
  128.   static bool nameAlreadyInDir( const QString&, K3bDirItem* );
  129.  
  130.   /**
  131.    * Most of the options that map to the mkisofs parameters are grouped
  132.    * together in the K3bIsoOptions class to allow easy saving to and loading
  133.    * from a KConfig object.
  134.    */
  135.   const K3bIsoOptions& isoOptions() const { return m_isoOptions; }
  136.   void setIsoOptions( const K3bIsoOptions& );
  137.  
  138.   const QPtrList<K3bBootItem>& bootImages() { return m_bootImages; }
  139.   K3bDataItem* bootCataloge() { return m_bootCataloge; }
  140.  
  141.   K3bDirItem* bootImageDir();
  142.  
  143.   /**
  144.    * Create a boot item and also create a boot cataloge file in case none
  145.    * exists in the project.
  146.    *
  147.    * Calling this method has the same effect like creating a new K3bBootItem 
  148.    * instance manually and then calling createBootCatalogeItem.
  149.    *
  150.    * \return The new boot item on success or 0 in case a file with the same
  151.    *         name already exists.
  152.    */
  153.   K3bBootItem* createBootItem( const QString& filename, K3bDirItem* bootDir = 0 );
  154.  
  155.   /**
  156.    * Create a new boot catalog item.
  157.    * For now this is not called automatically for internal reasons.
  158.    *
  159.    * Call this if you create boot items manually instead of using createBootItem.
  160.    *
  161.    * The boot catalog is automatically deleted once the last boot item is removed
  162.    * from the doc.
  163.    *
  164.    * \return The new boot catalog item or the old one if it already exists.
  165.    */
  166.   K3bDataItem* createBootCatalogeItem( K3bDirItem* bootDir );
  167.  
  168.   /**
  169.    * This will prepare the filenames as written to the image.
  170.    * These filenames are saved in K3bDataItem::writtenName
  171.    */
  172.   void prepareFilenames();
  173.  
  174.   /**
  175.    * Returns true if filenames need to be cut due to the limitations of Joliet.
  176.    *
  177.    * This is only valid after a call to @p prepareFilenames()
  178.    */
  179.   bool needToCutFilenames() const { return m_needToCutFilenames; }
  180.  
  181.   const QValueList<K3bDataItem*>& needToCutFilenameItems() const { return m_needToCutFilenameItems; }
  182.  
  183.   /**
  184.    * Imports a session into the project. This will create K3bSessionImportItems
  185.    * and properly set the imported session size.
  186.    * Some settings will be adjusted to the imported session (joliet, rr).
  187.    * 
  188.    * Be aware that this method is blocking.
  189.    *
  190.    * \return true if the old session was successfully imported, false if no
  191.    *         session could be found.
  192.    *
  193.    * \see clearImportedSession()
  194.    */
  195.   bool importSession( K3bDevice::Device* );
  196.  
  197.   bool sessionImported() const;
  198.  
  199.   /**
  200.    * Searches for an item by it's local path.
  201.    *
  202.    * NOT IMPLEMENTED YET!
  203.    *
  204.    * \return The items that correspond to the specified local path.
  205.    */
  206.   QValueList<K3bDataItem*> findItemByLocalPath( const QString& path ) const;
  207.  
  208.  public slots:
  209.   virtual void addUrls( const KURL::List& urls );
  210.  
  211.   /**
  212.    * Add urls syncroneously
  213.    * This method adds files recursively including symlinks, hidden, and system files.
  214.    * If a file already exists the new file's name will be appended a number.
  215.    */
  216.   virtual void addUrls( const KURL::List& urls, K3bDirItem* dir );
  217.  
  218.   void clearImportedSession();
  219.  
  220.   /**
  221.    * Just a convience method to prevent using setIsoOptions for this
  222.    * often used value.
  223.    */
  224.   void setVolumeID( const QString& );
  225.  
  226.  signals:
  227.   void itemRemoved( K3bDataItem* );
  228.   void itemAdded( K3bDataItem* );
  229.  
  230.  protected:
  231.   /** reimplemented from K3bDoc */
  232.   virtual bool loadDocumentData( QDomElement* root );
  233.   /** reimplemented from K3bDoc */
  234.   virtual bool saveDocumentData( QDomElement* );
  235.  
  236.   void saveDocumentDataOptions( QDomElement& optionsElem );
  237.   void saveDocumentDataHeader( QDomElement& headerElem );
  238.   bool loadDocumentDataOptions( QDomElement optionsElem );
  239.   bool loadDocumentDataHeader( QDomElement optionsElem );
  240.  
  241.   K3bFileCompilationSizeHandler* m_sizeHandler;
  242.  
  243.   //  K3bFileCompilationSizeHandler* m_oldSessionSizeHandler;
  244.   KIO::filesize_t m_oldSessionSize;
  245.  
  246.  private:
  247.   void prepareFilenamesInDir( K3bDirItem* dir );
  248.   void createSessionImportItems( const K3bIso9660Directory*, K3bDirItem* parent );
  249.  
  250.   /**
  251.    * used by K3bDirItem to inform about removed items.
  252.    */
  253.   void itemRemovedFromDir( K3bDirItem* parent, K3bDataItem* removedItem );
  254.   void itemAddedToDir( K3bDirItem* parent, K3bDataItem* addedItem );
  255.  
  256.   /**
  257.    * load recursivly
  258.    */
  259.   bool loadDataItem( QDomElement& e, K3bDirItem* parent );
  260.   /**
  261.    * save recursivly
  262.    */
  263.   void saveDataItem( K3bDataItem* item, QDomDocument* doc, QDomElement* parent );
  264.  
  265.   void informAboutNotFoundFiles();
  266.  
  267.   QStringList m_notFoundFiles;
  268.   QStringList m_noPermissionFiles;
  269.  
  270.   K3bRootItem* m_root;
  271.  
  272.   int m_dataMode;
  273.  
  274.   bool m_verifyData;
  275.  
  276.   KIO::filesize_t m_size;
  277.         
  278.   K3bIsoOptions m_isoOptions;
  279.  
  280.   MultiSessionMode m_multisessionMode;
  281.   QPtrList<K3bDataItem> m_oldSession;
  282.  
  283.   // boot cd stuff
  284.   K3bDataItem* m_bootCataloge;
  285.   QPtrList<K3bBootItem> m_bootImages;
  286.  
  287.   bool m_bExistingItemsReplaceAll;
  288.   bool m_bExistingItemsIgnoreAll;
  289.  
  290.   bool m_needToCutFilenames;
  291.   QValueList<K3bDataItem*> m_needToCutFilenameItems;
  292.  
  293.   friend class K3bMixedDoc;
  294.   friend class K3bDirItem;
  295. };
  296.  
  297. #endif
  298.